/*
 *      skydome.cpp
 *      
 *      Copyright 2009 Víctor Manuel Ochoa <kanito8a@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#include "skydome.h"

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
Skydome::Skydome()
	: Entity()
{
	
}


/*
 * 
 * name: desconocido
 * @param
 * @return
 */
Skydome::~Skydome()
{
	
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
bool Skydome::init(Texture *_texture)
{
	Entity::init();
	if(!_texture)
		return false;
		
	m_texture=_texture;
	for(int i=0;i<3;i++)
	{
		m_color1[i]=1.f;
		m_color2[i]=1.f;
	}
	
	return true;
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
bool Skydome::init(float _color1[3],float _color2[3])
{
	Entity::init();
	for(int i=0;i<3;i++)
	{
		m_color1[i]=_color1[i];
		m_color2[i]=_color2[i];
	}

	m_texture=0;
	return true;
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
bool Skydome::init(Texture *_texture,float _color1[3],float _color2[3])
{
	Entity::init();
	for(int i=0;i<3;i++)
	{
		m_color1[i]=_color1[i];
		m_color2[i]=_color2[i];
	}

	m_texture=_texture;
	return true;
	
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
void Skydome::freeMemory()
{
	m_texture=0;
}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
void Skydome::draw()
{
	if(m_texture)
		m_texture->bind();
	else
		glBindTexture( GL_TEXTURE_2D, 0 );
	
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(0.f,0.f,0.f);
	glDisable( GL_BLEND );

	
    glBegin(GL_QUADS);
      glColor3fv(m_color1);
	  glTexCoord2f(0.f,0.f);
	  glVertex2f(0,0);	  	  
      glTexCoord2f(1.f,0.f);
	     
	  glVertex2f(640,0);  
	  
      glColor3fv(m_color2);	  
      
	  glTexCoord2f(1.f,1.f);   
	  glVertex2f(640,480);	  
      glTexCoord2f(0.f,1.f);   
	  
	  glVertex2f(0,480);
    glEnd();
	
	glPopMatrix();

}

/*
 * 
 * name: desconocido
 * @param
 * @return
 */
void Skydome::update()
{

}

